<template>
  <div>
    <div class="app-container dealerdetail_container">
      <div class="page_header gongyuan_header">中介人员详情</div>

      <div class="detail_page">
        <div class="row">
          <div class="detail_label gongyuan_content">登录名:</div>
          <div class="detail_value gongyuan_content_value">{{formData.userName}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">姓名:</div>
          <div class="detail_value gongyuan_content_value">{{formData.nickName}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">联系方式:</div>
          <div class="detail_value gongyuan_content_value">{{formData.phonenumber}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">是否禁用:</div>
          <div class="detail_value gongyuan_content_value">{{superStatus}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">身份证号:</div>
          <div class="detail_value gongyuan_content_value">{{formData.cardId}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">性别:</div>
          <div class="detail_value gongyuan_content_value">{{superSex}}</div>
        </div>
        <div class="row">
          <div class="detail_label gongyuan_content">提成比例:</div>
          <div class="detail_value gongyuan_content_value">
            {{formData.rate}}%
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { getAgentDetail } from '@/api/agent/agent'
export default {
  name: 'Agentdetail',
  components: {},
  data() {
    return {
      formData: {
        userName:undefined,
        nickName:undefined,
        cardId:undefined,
        phonenumber:undefined,
        sex:"0",
        status:"0",
        rate:""
      }
    }
  },
  computed: {
    ID() {
      return this.$route.query.id
    },
    superSex() {
      return this.findSelectText(this.formData.sex, [{label:"男",value:"0"},{label:"女",value:"1"}])
    }
    ,
    superStatus() {
      return this.findSelectText(this.formData.status, [{label:"启用",value:"0"},{label:"禁用",value:"1"}])
    }
  },
  async created() {
  },
  async mounted() {
    try {
      const res = await getAgentDetail(this.ID)
      this.formData = Object.assign(this.formData, res.data)
    } catch (error) {
      console.log(error)
    }
  },
  // 编辑类不缓存
  // async activated() {
  // },
  methods: {
    findSelectText(value, options) {
      const obj = options.find((item) => {
        return item.value === value
      }) || { lable: '' }
      return obj.label
    }
  }
}
</script>

<style lang='scss'>
.dealerdetail_container {
  .detail_page {
    .detail_label {
      width: 150px;
    }
  }
}
</style>



